﻿using AutoTest.Business.Dto.Goods;
using AutoTest.Business.IServices;
using AutoTest.Business.Vo.Goods;
using AutoTest.Framework.Api;
using AutoTest.Framework.Pager;
using Microsoft.AspNetCore.Mvc;

namespace AutoTest.WebApi.Controllers
{
    /// <summary>
    /// 
    /// </summary>
    [Route("api/goods")]
    public class GoodsController(IGoogdsService googdsService) : Controller
    {
        private readonly IGoogdsService _googdsService = googdsService;

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="searchDto"></param>
        /// <returns></returns>
        [HttpGet("page")]
        public async Task<ApiResult<PagedList<GoodsListVo>>> QueryGoodsPagerListAsync([FromBody] GoodsPageSearchDto searchDto)
        {
            return await ApiResult<PagedList<GoodsListVo>>.Successed(() => _googdsService.SearchGoodsAsync(searchDto));
        }
        /// <summary>
        /// 查询列表
        /// </summary>
        /// <param name="searchDto"></param>
        /// <returns></returns>
        [HttpGet("list")]
        public async Task<ApiResult<List<GoodsListVo>>> QueryGoodsListAsync([FromBody] GoodsSearchDto searchDto)
        {
            return await ApiResult<List<GoodsListVo>>.Successed(() => _googdsService.SearchGoodsAsync(searchDto));
        }
    }
}
